package javaMSCRM;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

/**
 * @author Zoran IVANOV
 *
 */
public class Menu extends JMenuBar  implements ActionListener{
	private static final long serialVersionUID = 1L;
	JMenu FileMenu = new JMenu("Menu");
	JMenu SettingsMenu = new JMenu("Settings");
	JMenuItem UsersMenu, ActivitiesMenu, AccountsMenu, LeadsMenu, OpportunitiesMenu, ContactsMenu, SettingsMenuItem;
	JavaMSCRM JavaMSCRM = null;

	/**
	 * @param JavaMSCRM
	 */
	public Menu(JavaMSCRM JavaMSCRM) {
		this.JavaMSCRM = JavaMSCRM;
		FileMenu.add(ActivitiesMenu = new JMenuItem("Activities"));
		FileMenu.add(AccountsMenu = new JMenuItem("Accounts"));
		FileMenu.add(ContactsMenu = new JMenuItem("Contacts"));
		FileMenu.add(LeadsMenu = new JMenuItem("Leads"));
		FileMenu.add(OpportunitiesMenu = new JMenuItem("Opportunities"));
		FileMenu.add(UsersMenu = new JMenuItem("Users"));
		SettingsMenu.add(SettingsMenuItem = new JMenuItem("Settings"));
		
		ActivitiesMenu.addActionListener(this);
		AccountsMenu.addActionListener(this);
		ContactsMenu.addActionListener(this);
		LeadsMenu.addActionListener(this);
		OpportunitiesMenu.addActionListener(this);
		UsersMenu.addActionListener(this);
		SettingsMenuItem.addActionListener(this);
		
		add(FileMenu);
		add(SettingsMenu);
	}
	
	/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	public void actionPerformed(ActionEvent e) {
		if(e.getSource () == UsersMenu){
        	//new UsersList(JavaMSCRM, true);
        	new Users(JavaMSCRM);
        }else if(e.getSource () == AccountsMenu){
        	new Accounts(JavaMSCRM);
        }else if(e.getSource () == ContactsMenu){
        	new Contacts(JavaMSCRM);
        }else if(e.getSource () == LeadsMenu){
        	new Leads(JavaMSCRM);
        }else if(e.getSource () == OpportunitiesMenu){
        	new Opportunities(JavaMSCRM);
        }else if(e.getSource () == ActivitiesMenu){
        	new Activities(JavaMSCRM);
        }else if(e.getSource () == SettingsMenuItem){
        	new Settings(true);
        }		
	}
}